package xin.mashibo.pattern.facade;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

/**
 * @author MaShibo
 * 日期 :  2019/1/24
 */
public class PageMaker {

    private PageMaker() {
    }

    public static void makeWelcomePage(String mailaddr, String filename) {
        Properties mailprop = Database.getProperties("maildata");
        String userName = mailprop.getProperty(mailaddr);
        try {
            HtmlWriter writer = new HtmlWriter(new FileWriter(filename));
            try {
                writer.title("Welcome to " + userName + "'s page!");
                writer.paragraph("等着你的邮件哦！");
                writer.mailto(mailaddr, userName);
            } finally {
                writer.close();
            }
            System.out.println(filename + " is created fro " + mailaddr + " (" + userName + ")");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
